class Solution {
    public int minEatingSpeed(int[] piles, int h) {
        int left = 0;
        int right = (int)1e9;
        while (left < right)
        {
            int mid = left + right >> 1;
            if (check(piles, mid) > h)
            {
                left = mid + 1;
            }
            else
                right = mid;
        }
        return right;
    }
    public int check(int[] arr, int mid)
    {
        int ans = 0;
        for (int x : arr)
        {
            ans += Math.ceil(x * 1.0 / mid);
        }
        return ans;
    }
}